﻿using System;

namespace Eneta.Portal.FeedAggregator
{
    public class FeedItem : IEquatable<FeedItem>
    {
        public String Title { get; set; }
        public String Description { get; set; }
        public DateTime PublishDate { get; set; }
        public Uri Url { get; set; }
        public int BlogId { get; set; }
        public String Categories { get; set; }
        public string ImageUrl { get; set; }
        public string ImageUrlTarget { get; set; }
        public string SourceTitle { get; set; }


        /// <summary>
        /// Indicates whether the current object is equal to another object of the same type.
        /// </summary>
        /// <returns>
        /// true if the current object is equal to the <paramref name="otherItem" /> parameter; otherwise, false.
        /// </returns>
        /// <param name="otherItem">An object to compare with this object.</param>
        public bool Equals(FeedItem otherItem)
        {
            if ((Url == null && otherItem.Url == null) || Url.Equals(otherItem.Url))
            {
                return true;
            }
            return false;
        }

        public override bool Equals(object obj)
        {
            var otherItem = obj as FeedItem;
            if (otherItem == null) return false;
            return Equals(otherItem);
        }

        public override int GetHashCode()
        {
            return Url.GetHashCode();
        }
    }
}